package ru.ifmo.mlarinsky.classificator.gui;

import java.util.List;
import javax.swing.*;

import net.miginfocom.swing.MigLayout;
import ru.ifmo.mlarinsky.classificator.accuracy.ClassificationEfficiencyCalculator;
import ru.ifmo.mlarinsky.classificator.classification.Classification;
import ru.ifmo.mlarinsky.classificator.classification.DJClassification;
import ru.ifmo.mlarinsky.classificator.classification.SPClassification;
import ru.ifmo.mlarinsky.classificator.io.InstrumentLoader;
import ru.ifmo.mlarinsky.classificator.map.*;
import ru.ifmo.mlarinsky.classificator.model.Instrument;
import ru.ifmo.mlarinsky.classificator.model.QuoteDate;
import ru.ifmo.mlarinsky.classificator.providers.DeterminationVectorProvider;
import ru.ifmo.mlarinsky.classificator.providers.InstructionsProvider;
import ru.ifmo.mlarinsky.classificator.providers.ReturnHistoryVectorProvider;
import ru.ifmo.mlarinsky.classificator.providers.VectorProvider;

public class MapPanel extends JPanel {
    private final SomMap map;
    private final Classification classification;

    public MapPanel(SomMap map, Classification classification) {
        super(new MigLayout("fill"));
        this.map = map;
        this.classification = classification;

        initLayout();
    }

    private void initLayout() {
        JPanel mapPanel = new JPanel(new MigLayout("fill, ins 0, gap 0"));

        int x = 1;
        String wrapConstraint = "";
        for (MapNode mapNode : map) {
            MapNodePanel mapNodePanel = new MapNodePanel(mapNode);

            wrapConstraint = (x++ % map.getXDimension() == 0) ? ", wrap" : "";
            mapPanel.add(mapNodePanel, "grow, push" + wrapConstraint);
        }

        MapLegendPanel mapLegendPanel = new MapLegendPanel(classification);
        add(mapPanel, "left, h pref!, w pref!");
        add(new JSeparator(JSeparator.VERTICAL));
        add(mapLegendPanel, "right, grow, pushx");
    }

}
